<?php

/**
 * @author Alexandr McArrow
 * @copyright 2008
 * @project Board Site
 */

include_once "RSi.php";
$RSi->RSi_start();


define("BOARDSITE","");

include_once "config.php";
include_once "function.php";

/////////////////////////////////////////////
clear_old_and_bad_post();
/////////////////////////////////////////////
clear_old_captcha();
/////////////////////////////////////////////


$CONTENT = "";
$TITLE = "";
$LINKTITLE = "";
$MENU = "";


/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////

if (isset($_REQUEST['god']))
{
	if(isset($_REQUEST['allpostdone']))
	{
		$query = "UPDATE `board_post` SET `show`='1' WHERE 1";
		SQL_count_query($query);
		$CONTENT = "<div class='infoblock'><b>GOD MODE EXECUTE</b> ALLPOSTDONE <b>SUCCESSFUL</b></div>";
		$TITLE = "GOD MODE EXECUTE";
	}
	
	if(isset($_REQUEST['htaccess']))
	{
		if($_REQUEST['htaccess'] == "rewrite")
		{
		if(hta_rewrite() == 0)
		{
		$CONTENT = "<div class='infoblock'><b>GOD MODE EXECUTE</b> HTACCESS REWRITE <b>SUCCESSFUL</b></div>";
		}
		else
		{
		$CONTENT = "<div class='infoblock'><b>GOD MODE EXECUTE</b> HTACCESS REWRITE ERROR <b>SUCCESSFUL</b></div>";	
		}
		$TITLE = "GOD MODE EXECUTE";	
		}
		else
		{
			$hta = "<div class='infoblock'>";
			
			foreach ($BS['PREF'] as $key=>$value)
			{
				$hta .= $key." - ".$value."<br>";
			}
			$hta .= "</div>";
			
		$CONTENT = "<div class='infoblock'><b>GOD MODE EXECUTE</b> HTACCESS SHOW <b>SUCCESSFUL</b>".$hta."</div>";
		$TITLE = "GOD MODE EXECUTE";
		}
	}
	
	if(isset($_REQUEST['setdebug']))
	{
		if (($_REQUEST['setdebug'] == "0") or ($_REQUEST['setdebug'] == ""))
		{
		unset($_SESSION['godmodesetdebug']);
		$CONTENT = "<div class='infoblock'><b>GOD MODE EXECUTE</b> SETDEBUG=0 <b>SUCCESSFUL</b></div>";
		$TITLE = "GOD MODE EXECUTE";
		}
		else
		{
		$_SESSION['godmodesetdebug']=$_REQUEST['setdebug'];
		$CONTENT = "<div class='infoblock'><b>GOD MODE EXECUTE</b> SETDEBUG=".$_SESSION['godmodesetdebug']." <b>SUCCESSFUL</b></div>";
		$TITLE = "GOD MODE EXECUTE";
		}
	}
	
}

if(isset($_SESSION['godmodesetdebug']))
{
	$BS['ALLOWDEBUG']=$_SESSION['godmodesetdebug'];
}


if ($BS['ALLOWDEBUG'] >= 3)
{
	$OUT="<a onclick='javascript:expand(\"request\");'><b>&gt; REQUEST</b></a><div id='request' style='display:none'>";
	
	foreach ($_REQUEST as $key=>$value)
	{
		$OUT.=$key." = ".$value."<br>";
	}
	$OUT.="</div>";
	
	$BS['DEBUG'][]=$OUT;	
}

if ($BS['ALLOWDEBUG'] >= 3)
{
	$OUT="<a onclick='javascript:expand(\"session\");'><b>&gt; SESSION</b></a><div id='session' style='display:none'>";
	
	foreach ($_SESSION as $key=>$value)
	{
		$OUT.=$key." = ".$value."<br>";
	}
	$OUT.="</div>";
	
	$BS['DEBUG'][]=$OUT;	
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////


if (isset($_REQUEST['cat']))
{
	$_SESSION['cat']=$_REQUEST['cat'];
}
else
{
	$_SESSION['cat']="-";
}

if (isset($_REQUEST['post']))
{
	$_SESSION['post']=$_REQUEST['post'];
}
else
{
	$_SESSION['post']="-";
}



if(isset($_REQUEST['search']))
{	
    $CONTENT = search_all();
} 


if(isset($_REQUEST['newpost']))
{	
	include_once "post.php";
    $CONTENT = work_new_post();
} 


if(isset($_REQUEST['board']))
{	
	include_once "board.php";
    $CONTENT = work_old_post();
} 

if(isset($_REQUEST['stat']))
{	
	include_once "stat.php";
    $CONTENT = work_stat();
} 

if(isset($_REQUEST['page']))
{
    $CONTENT = get_page();
}

if (isset($_REQUEST['verif']))
{	
	$CONTENT = verif_added_post();
}


if (isset($_REQUEST['tag']))
{
	$CONTENT = tags_search($_REQUEST['tagname']);
}


/////////////////////
/////////////////////

$BODY = "";

Template_parse();

/////////////////////
/////////////////////


/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////

foreach($BS['PREF'] as $key => $value)
{
	$BODY = str_replace("[".$key."]",$value,$BODY);
}

$DEBUG = "<script>function expand(obj)
	{
		var curvis;
		curvis = document.getElementById(obj).style.display;
		if (curvis == \"none\") document.getElementById(obj).style.display = \"block\";
 		else document.getElementById(obj).style.display = \"none\";
	};	</script><div id='BSdebug' style='display:none'>";


foreach ($BS['DEBUG'] as $value)
{
	$DEBUG.="<div>".$value."</div>";
}
$DEBUG .= "</div></div>";


/////////////////////
/////////////////////

echo $BODY;

/////////////////////
/////////////////////



if ($BS['ALLOWDEBUG']>=1)
{
	
$RSi->RSi_stop();
	
echo "<style type=\"text/css\">
<!--
#PARTICULA {font-family: Tahoma;font-size: 7px;font-weight: normal;color: #333333;background-color: #DDDDDD;display: block;padding-top: 3px;padding-right: 5px;padding-bottom: 3px;padding-left: 5px;text-align: center;position: fixed;width: 350px;border: 1px dotted #333333;z-index: 20;bottom: 5px;right: 5px;visibility: visible;overflow: visible;}
#BSdebug {font-family: Tahoma;font-size: 7px;font-weight: normal;color: #333333;text-decoration: none;background-color: #FFFFCC;padding: 1px;border: 1px solid #666666;}
#BSdebug div {margin: 2px;padding: 2px;border: 1px solid #999999;text-align: left;}
-->
</style>\r\n";	

echo "<div id='PARTICULA'><b>".$BS['ADM']['VN']." (".$BS['ADM']['VA'].")</b><br>RSi [".$RSi->RSi."] QC [".$BS['SQLquery']."] GT [".$RSi->Time."]<hr><a onclick='expand(\"BSdebug\");'><b>DEBUG DATA</b></a>".$DEBUG."</div>";
}


?>